<template>
  <div style="margin: 0 auto;width: 600px">
    <el-descriptions class="margin-top" title="用户信息" :column="3" :size="size" border>
      <template slot="extra">
        <el-button type="primary" size="small" @click="logOut">退出登录</el-button>
      </template>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"></i>
          用户名
        </template>
        {{this.$store.state.user.userId}}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-mobile-phone"></i>
          昵称
        </template>
        {{this.$store.state.user.userName}}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-office-building"></i>
          联系地址
        </template>
        {{this.$store.state.user.address}}
      </el-descriptions-item>
    </el-descriptions>

  </div>
</template>

<script>
import {get} from "@/util/axios";

export default {
  name: "HomeIndex",
  methods:{
    logOut(){
      get('/doLogOut').then(res=>{
        if(res && res.data){
          // 清空本地缓存
          sessionStorage.clear();
          // 跳转首页
          this.$router.replace('/login');
          window.location.reload();
          this.$message.success(res.msg);
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
